﻿using ET.DBCommon.DAL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace ET.ScoreTeacherClient.Views
{
    /// <summary>
    /// SubmitelementEdit.xaml 的交互逻辑
    /// </summary>
    public partial class SubmitelementEdit : Window
    {
        public SubmitelementViewModel viewModel { get; set; }
        public SubmitelementEdit(SubmitelementViewModel _viewModel)
        {
            InitializeComponent();
            this.viewModel = _viewModel;
            this.DataContext = this;
        }

        public SubmitelementEdit()
        {
            InitializeComponent();
        }

        private void BtnSave_Click(object sender, RoutedEventArgs e)
        {
            if (viewModel.ID == 0)
            {
                int newId = 0;
                if (SubmitelementDAL.InsertSubmitelement(out newId, viewModel.Model))
                {
                    viewModel.ID = newId;
                    this.DialogResult = true;
                }
            }
            //else if (SubmitelementDAL.UpdateSubmitelement(viewModel.Model))
            //{
            //    this.DialogResult = true;
            //}
        }

        private void BtnCancel_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }
    }
}
